package com.example.controller;

import com.example.entity.Result;
import com.example.entity.dto.EmpLoginDto;
import com.example.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EmpLoginController {
    @Autowired
    private EmpService empService;
    @PostMapping("/login")
    public Result<String> login(EmpLoginDto empLoginDto) {
        //成功登录，返回token，失败返回null，并给前端传递NOT_LOGIN_ERROR
        Result<String> result = empService.login(empLoginDto);
        return result == null ? Result.error("NOT_LOGIN_ERROR") : result;
    }
}
